<?php
/**
 * JoiGallery - image gallery component for Joostina
 *
 * Редактирование фотографии
 *
 * @version 1.0 alpha 12
 * @package JoiGallery
 * @subpackage	AdminView
 * @filename item_form.php
 * @author JoostinaTeam
 * @copyright (C) 2008-2009 Joostina Team
 * @license see license.txt
 *
 **/
 
defined('_VALID_MOS') or die();

//Загружаем jQuery
mosCommonHTML::loadJquery();
//Загружаем FancyBox
mosCommonHTML::loadJqueryPlugins('fancybox/jquery.fancybox',false, true);
//Загружаем библиотеку всплывающих подсказок
mosCommonHTML::loadOverlib();

$tabs = new mosTabs(1, 1);

//Параметры оригинала

//Размеры. Индекс 0 содержит ширину/width изображения в пикселах. Индекс 1 содержит высоту/height.
$dim  = getimagesize (JPATH_SITE.$params->original_path.'/'.$row->path);
$size = round(filesize(JPATH_BASE.$params->original_path.'/'.$row->path)/1024,2); 
?>

<script language="javascript" type="text/javascript">
  function submitbutton(pressbutton) {
      var form = document.adminForm;
      if (pressbutton == 'cancel') {
              submitform( pressbutton );
              return;
      }
      if (pressbutton == 'save') {              
              if (!$('#name').val()) {
                alert('<?php echo _C_JOIGALLERY_MSG_SAVE_ERR_IMG_NAME_EMPTY; ?>');
                $("form").submit(function () { return false; });
              }
              else {
                <?php getEditorContents( 'editor1', 'description' ) ; ?>
                submitform(pressbutton);
              }
      }
      
  }
  function ch_apply(){
    var form = document.adminForm;
    if (!$('#name').val()) {
      alert('<?php echo _C_JOIGALLERY_MSG_SAVE_ERR_IMG_NAME_EMPTY; ?>');
      return false;
    }
	else $(".change_name").text(form.name.value);
    SRAX.get('tb-apply').className='tb-load';
    <?php getEditorContents( 'editor1', 'description' ) ; ?>
    dax({
          url: 'ajax.index.php?option=com_joigallery&act=photos&task=apply',
          id:'publ-1',
          method:'post',
          form: 'adminForm',
          callback:
                  function(resp){
                  log('Получен ответ: ' + resp.responseText);
                  mess_cool(resp.responseText);
                  SRAX.get('tb-apply').className='tb-apply';
          }});
  }
</script>

<table class="adminheading">
  <tr>
    <th class="categories">
     <?php echo _C_JOIGALLERY_COMPONENT;
           echo $row->id ? _C_JOIGALLERY_PHOTO_EDIT.'&nbsp;::&nbsp;<span class="change_name">'.$row->name.'</span>' 
		                 : _C_JOIGALLERY_PHOTO_ADD;
      ?>
    </th> 
  </tr>
</table>

<form action="index2.php" method="post" name="adminForm" id="adminForm">

  <?php $tabs->startPane("photo"); ?>
  <?php $tabs->startTab(_C_JOIGALLERY_COMMON, "photo-0"); ?>
  
  <table class="adminform" border="0">
    <tr>
      <td colspan="4">&nbsp;</td>
    </tr>
    <tr>
      <td class="pl20" width="150"><?php echo _C_JOIGALLERY_NAME ?></td>
      <td><input type="text" name="name" id="name" class="text_area" size="30" value="<?php echo $row->name; ?>" /></td>
      <td rowspan="4" align="right" valign="top">
        <table cellspacing="0" cellpadding="0" class="mr20 gray">
          <tr>
            <td>Ширина</td>
            <td class="pl20"><?php echo $dim[0].'&nbsp;'._C_JOIGALLERY_PX; ?></td>
          </tr>
          <tr>
            <td>Высота</td>
            <td class="pl20"><?php echo $dim[1].'&nbsp;'._C_JOIGALLERY_PX; ?></td>
          </tr>
          <tr>
            <td><?php echo _C_JOIGALLERY_MIME_TYPE; ?></td>
            <td class="pl20"><?php echo joiGalleryHelper::get_mimetype($row->path); ?></td>
          </tr>
          <tr>
            <td>Размер файла</td>
            <td class="pl20"><?php echo $size.'&nbsp;'._C_JOIGALLERY_KB; ?></td>
          </tr>
          </table>
      </td>
	  <?php if ($params->get('adm_img_form_thumbs')) { ?>
      <td rowspan="5" valign="top" width="110" class="pr20">
		<?php if ($params->get('adm_img_form_thumbs_fb')) { ?>
		  <a class="thumb" target="_blank" href="<?php echo JPATH_SITE.$params->original_path.'/'.$row->path; ?>" title="<?php echo $row->name; ?>">
		    <?php    echo joiGalleryHelper::imgThumb ($thumb_source, $row->path, $params, 'item_form') ?>
		  </a>
		<?php } else echo joiGalleryHelper::imgThumb ($thumb_source, $row->path, $params, 'item_form')  ?>
      </td>
	  <?php }//if ?>
    </tr>
    <tr>
      <td class="pl20"><?php echo _C_JOIGALLERY_CATEGORY ?></td>
      <td><?php echo $lists['cid']; ?></td>
    </tr>
    <tr>
      <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
      <td class="pl20"><?php echo _C_JOIGALLERY_PHOTO_GALLERY_THUMBNAIL ?></td>
      <td><?php echo mosHTML::yesnoRadioList('default', '', $row->default); ?></td>
    </tr>
    <tr class="pl20">
      <td class="pl20"><?php echo _C_JOIGALLERY_PUBLISHED ?></td>
      <td><?php echo mosHTML::yesnoRadioList('state', '', $row->state); ?></td>
    </tr>
    <tr>
      <td colspan="3">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>    
    <tr valign="top">
      <td class="pl20"><?php echo _C_JOIGALLERY_DESCRIPTION ?></td>
      <td colspan="2" style="padding-right:20px">
        <?php // parameters : areaname, content, hidden field, width, height, rows, cols
          editorArea( 'editor1',  $row->description , 'description', '100%;', '100', '60', '20' ) ;
        ?>
      </td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="4">&nbsp;</td>
    </tr>
  </table>

  <?php $tabs->endTab(); ?>
  <?php $tabs->startTab(_C_JOIGALLERY_META, "photo-1"); ?>

  <table class="adminform">
    <tr>
      <td colspan="3">&nbsp;</td>
    </tr>
    <tr>
      <td class="pl20 title"><?php echo _C_JOIGALLERY_TITLE ?> <?php echo mosToolTip(_C_JOIGALLERY_CONF_META_TITLE_TIP); ?></td>
      <td><textarea class="txta1" rows="2" cols="80" name="meta_title"><?php echo $row->meta_title ?></textarea></td>
      <td>&nbsp;</td>
    </tr>    
    <tr>
      <td class="pl20 title"><?php echo _C_JOIGALLERY_DESCRIPTION ?> <?php echo mosToolTip(_C_JOIGALLERY_CONF_META_DESC_TIP); ?></td>
      <td><textarea class="txta1" rows="2" cols="80" name="meta_desc"><?php echo $row->meta_desc ?></textarea></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td class="pl20 title"><?php echo _C_JOIGALLERY_KW ?> <?php echo mosToolTip(_C_JOIGALLERY_CONF_META_KW_TIP); ?></td>
      <td><textarea  class="txta1" rows="2" cols="80" name="meta_kw"><?php echo $row->meta_kw ?></textarea></td>
      <td align="left">
        <a class="iframe" href="http://wordstat.yandex.ru/advq?rpt=ppc&key=&shw=1&tm=&checkboxes=&text=">
          <img src="<?php JPATH_SITE ?>/images/M_images/yandex.png" 
               alt="Яндекс" border="0"
               title="<?php echo _C_JOIGALLERY_CONF_META_KW_STAT ?>" />
        </a>
      </td>
    </tr>
    <tr>
      <td colspan="3">&nbsp;</td>
    </tr>
  </table>  

  <?php $tabs->endTab(); ?>
  <?php $tabs->endPane(); ?>

  <input type="hidden" name="id" value="<?php echo $row->id; ?>" />
  <input type="hidden" name="option" value="<?php echo $option; ?>" />
  <input type="hidden" name="task" value="" />
  <input type="hidden" name="act" value="photos" />
  <input type="hidden" name="boxchecked" value="0" />
  <input type="hidden" name="hidemainmenu" value="0" />
  
</form>

<script type="text/javascript">

 //FancyBox
 $("a.iframe").fancybox({
    //"hideOnContentClick" : true,
    'frameWidth'  : 900, // ширина окна, px (425px - по умолчанию)
    'frameHeight' : 450 // высота окна, px(355px - по умолчанию)
 });
 
 $("a.thumb").fancybox();

</script>